package com.oschat.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.oschat.entity.enums.PageSize;
import com.oschat.entity.query.UserInfoPrettyQuery;
import com.oschat.entity.po.UserInfoPretty;
import com.oschat.entity.vo.PaginationResultVO;
import com.oschat.entity.query.SimplePage;
import com.oschat.mappers.UserInfoPrettyMapper;
import com.oschat.service.UserInfoPrettyService;
import com.oschat.utils.StringTools;


/**
 * 靓号表 业务接口实现
 */
@Service("userInfoPrettyService")
public class UserInfoPrettyServiceImpl implements UserInfoPrettyService {

	@Resource
	private UserInfoPrettyMapper<UserInfoPretty, UserInfoPrettyQuery> userInfoPrettyMapper;

	/**
	 * 根据条件查询列表
	 */
	@Override
	public List<UserInfoPretty> findListByParam(UserInfoPrettyQuery param) {
		return this.userInfoPrettyMapper.selectList(param);
	}

	/**
	 * 根据条件查询列表
	 */
	@Override
	public Integer findCountByParam(UserInfoPrettyQuery param) {
		return this.userInfoPrettyMapper.selectCount(param);
	}

	/**
	 * 分页查询方法
	 */
	@Override
	public PaginationResultVO<UserInfoPretty> findListByPage(UserInfoPrettyQuery param) {
		int count = this.findCountByParam(param);
		int pageSize = param.getPageSize() == null ? PageSize.SIZE15.getSize() : param.getPageSize();

		SimplePage page = new SimplePage(param.getPageNo(), count, pageSize);
		param.setSimplePage(page);
		List<UserInfoPretty> list = this.findListByParam(param);
		PaginationResultVO<UserInfoPretty> result = new PaginationResultVO(count, page.getPageSize(), page.getPageNo(), page.getPageTotal(), list);
		return result;
	}

	/**
	 * 新增
	 */
	@Override
	public Integer add(UserInfoPretty bean) {
		return this.userInfoPrettyMapper.insert(bean);
	}

	/**
	 * 批量新增
	 */
	@Override
	public Integer addBatch(List<UserInfoPretty> listBean) {
		if (listBean == null || listBean.isEmpty()) {
			return 0;
		}
		return this.userInfoPrettyMapper.insertBatch(listBean);
	}

	/**
	 * 批量新增或者修改
	 */
	@Override
	public Integer addOrUpdateBatch(List<UserInfoPretty> listBean) {
		if (listBean == null || listBean.isEmpty()) {
			return 0;
		}
		return this.userInfoPrettyMapper.insertOrUpdateBatch(listBean);
	}

	/**
	 * 多条件更新
	 */
	@Override
	public Integer updateByParam(UserInfoPretty bean, UserInfoPrettyQuery param) {
		StringTools.checkParam(param);
		return this.userInfoPrettyMapper.updateByParam(bean, param);
	}

	/**
	 * 多条件删除
	 */
	@Override
	public Integer deleteByParam(UserInfoPrettyQuery param) {
		StringTools.checkParam(param);
		return this.userInfoPrettyMapper.deleteByParam(param);
	}

	/**
	 * 根据Id获取对象
	 */
	@Override
	public UserInfoPretty getUserInfoPrettyById(Integer id) {
		return this.userInfoPrettyMapper.selectById(id);
	}

	/**
	 * 根据Id修改
	 */
	@Override
	public Integer updateUserInfoPrettyById(UserInfoPretty bean, Integer id) {
		return this.userInfoPrettyMapper.updateById(bean, id);
	}

	/**
	 * 根据Id删除
	 */
	@Override
	public Integer deleteUserInfoPrettyById(Integer id) {
		return this.userInfoPrettyMapper.deleteById(id);
	}

	/**
	 * 根据UserId获取对象
	 */
	@Override
	public UserInfoPretty getUserInfoPrettyByUserId(String userId) {
		return this.userInfoPrettyMapper.selectByUserId(userId);
	}

	/**
	 * 根据UserId修改
	 */
	@Override
	public Integer updateUserInfoPrettyByUserId(UserInfoPretty bean, String userId) {
		return this.userInfoPrettyMapper.updateByUserId(bean, userId);
	}

	/**
	 * 根据UserId删除
	 */
	@Override
	public Integer deleteUserInfoPrettyByUserId(String userId) {
		return this.userInfoPrettyMapper.deleteByUserId(userId);
	}

	/**
	 * 根据Email获取对象
	 */
	@Override
	public UserInfoPretty getUserInfoPrettyByEmail(String email) {
		return this.userInfoPrettyMapper.selectByEmail(email);
	}

	/**
	 * 根据Email修改
	 */
	@Override
	public Integer updateUserInfoPrettyByEmail(UserInfoPretty bean, String email) {
		return this.userInfoPrettyMapper.updateByEmail(bean, email);
	}

	/**
	 * 根据Email删除
	 */
	@Override
	public Integer deleteUserInfoPrettyByEmail(String email) {
		return this.userInfoPrettyMapper.deleteByEmail(email);
	}
}